/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kasgroup2;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 *
 * @author beha
 */
public class UICreateHotelFrame extends javax.swing.JFrame {

    private Hotel hotel = null;
    private Room selectedRoom = null;
    private HashMap<Room, Integer> rooms = null;
    private TableManager tmRooms = null;
    private TableManager tmRoomService = null;
    /**
     * Creates new form UICreateHotelFrame
     */
    public UICreateHotelFrame() {
        initComponents();
        //this.add(new UICreateHotel(), java.awt.BorderLayout.CENTER);
        this.rooms = new HashMap<Room, Integer>();
        this.tmRooms = new TableManager(this.tblRooms);
        this.tmRoomService = new TableManager(this.tblRoomService);
        this.tmRooms.clear();
        this.tmRoomService.clear();
        this.cmbRoomType.removeAllItems();
        for(EnumRoomType rt : EnumRoomType.values()) {
            this.cmbRoomType.addItem(rt);
        }
    }
    
    public UICreateHotelFrame(Hotel p_Hotel) {
        this();
        this.hotel = p_Hotel;
        if(p_Hotel != null) {
            this.jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Edit Hotel"));
            this.rooms = p_Hotel.getRooms();
            this.txtHotelName.setText(p_Hotel.getName());
            this.txtHotelAddress.setText(p_Hotel.getAddress());
            this.txtRoomAmount.setText(""+p_Hotel.getRoomCount());
            this.btnCreateHotel.setText("Save & Close");
            this.btnCreateHotel.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt ) {
                    try {
                        KASGroup2.getCoreHandlerInstance().updateHotel(getHotelInfo());
                        dispose();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            });
            Iterator it = rooms.entrySet().iterator();
            while(it.hasNext()) {
                Map.Entry pairs = (Map.Entry)it.next();
                addRow((Room)pairs.getKey(), (Integer)pairs.getValue());
            }
        }
        else {
            this.btnCreateHotel.addActionListener(new ActionListener() { 
                public void actionPerformed(ActionEvent evt) {
                    try {
                        KASGroup2.getCoreHandlerInstance().addHotel(getHotelInfo());
                        dispose();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            });
        }
    }
    
    private Hotel getHotelInfo() {
        int roomCount = 0;
        roomCount = Integer.parseInt(this.txtRoomAmount.getText());
        int hotelId = KASGroup2.getCoreHandlerInstance().getHotelList().size();
        if(this.hotel != null) {
            hotelId = this.hotel.getID();
        }
        return new Hotel(
                    hotelId,
                    this.txtHotelName.getText(),
                    this.txtHotelAddress.getText(),
                    this.rooms
                );
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txtHotelName = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtHotelAddress = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblRooms = new javax.swing.JTable();
        txtRoomAmount = new javax.swing.JFormattedTextField();
        cmbRoomType = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        btnAddRoomType = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtRoomPrice = new javax.swing.JFormattedTextField();
        btnDeleteRoom = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblRoomService = new javax.swing.JTable();
        txtRoomServiceName = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        btnAddRoomType1 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtRoomServiceDescription = new javax.swing.JFormattedTextField();
        btnDeleteRoom1 = new javax.swing.JButton();
        txtRoomServicePrice = new javax.swing.JFormattedTextField();
        btnCreateHotel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Create Hotel"));

        jLabel2.setText("Name:");

        jLabel3.setText("Address:");

        txtHotelAddress.setColumns(20);
        txtHotelAddress.setRows(5);
        jScrollPane2.setViewportView(txtHotelAddress);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Rooms"));

        tblRooms.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Type", "Amount", "Price"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Integer.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblRooms.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblRoomsMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblRooms);
        tblRooms.getColumnModel().getColumn(0).setResizable(false);
        tblRooms.getColumnModel().getColumn(1).setResizable(false);
        tblRooms.getColumnModel().getColumn(2).setResizable(false);

        txtRoomAmount.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        txtRoomAmount.setText("0");

        cmbRoomType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel4.setText("Amount:");

        btnAddRoomType.setText("Add");
        btnAddRoomType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddRoomTypeActionPerformed(evt);
            }
        });

        jLabel5.setText("Type:");

        jLabel6.setText("Price:");

        txtRoomPrice.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        txtRoomPrice.setText("0");

        btnDeleteRoom.setText("Delete");
        btnDeleteRoom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteRoomActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel4)
                            .add(jLabel5))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(txtRoomAmount)
                            .add(cmbRoomType, 0, 182, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel6)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel2Layout.createSequentialGroup()
                                .add(btnAddRoomType)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnDeleteRoom)
                                .add(0, 0, Short.MAX_VALUE))
                            .add(txtRoomPrice))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(txtRoomAmount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel6)
                    .add(txtRoomPrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel5)
                    .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(cmbRoomType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(btnAddRoomType)
                        .add(btnDeleteRoom)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Room Service"));

        tblRoomService.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "name", "Description", "Price"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblRoomService.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblRoomServiceMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tblRoomService);
        tblRoomService.getColumnModel().getColumn(0).setResizable(false);
        tblRoomService.getColumnModel().getColumn(1).setResizable(false);
        tblRoomService.getColumnModel().getColumn(2).setResizable(false);

        txtRoomServiceName.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        jLabel7.setText("Name:");

        btnAddRoomType1.setText("Add");
        btnAddRoomType1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddRoomType1ActionPerformed(evt);
            }
        });

        jLabel8.setText("Price:");

        jLabel9.setText("Description:");

        txtRoomServiceDescription.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        btnDeleteRoom1.setText("Delete");
        btnDeleteRoom1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteRoom1ActionPerformed(evt);
            }
        });

        txtRoomServicePrice.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));
        txtRoomServicePrice.setText("0");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane3)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel7)
                            .add(jLabel8))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel3Layout.createSequentialGroup()
                                .add(txtRoomServiceName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 182, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jLabel9))
                            .add(txtRoomServicePrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 182, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel3Layout.createSequentialGroup()
                                .add(btnAddRoomType1)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnDeleteRoom1)
                                .add(0, 0, Short.MAX_VALUE))
                            .add(txtRoomServiceDescription))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(txtRoomServiceName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel9)
                    .add(txtRoomServiceDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnAddRoomType1)
                    .add(btnDeleteRoom1)
                    .add(txtRoomServicePrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel8))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                .addContainerGap())
        );

        btnCreateHotel.setText("Create");
        btnCreateHotel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateHotelActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(12, 12, 12)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel1Layout.createSequentialGroup()
                                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel2)
                                    .add(jLabel3))
                                .add(26, 26, 26)
                                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(txtHotelName)
                                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 490, Short.MAX_VALUE)))
                            .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .add(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                        .add(0, 0, Short.MAX_VALUE)
                        .add(btnCreateHotel)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(txtHotelName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnCreateHotel)
                .addContainerGap(50, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAddRoomTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddRoomTypeActionPerformed
        
        int roomAmount = 0;
        roomAmount = Integer.parseInt(this.txtRoomAmount.getText());
        Room room = makeRoom();
        this.rooms.put(room, roomAmount);
        addRow(room , roomAmount);
    }//GEN-LAST:event_btnAddRoomTypeActionPerformed

    private void btnDeleteRoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteRoomActionPerformed
        this.rooms.remove(selectedRoom);
        this.tmRooms.removeSelectedRow();
    }//GEN-LAST:event_btnDeleteRoomActionPerformed

    private void tblRoomsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblRoomsMouseClicked
        EnumRoomType rt = EnumRoomType.valueOf(this.tmRooms.getCellValueForSelectedRow(0).toString());
        Integer amount = Integer.parseInt(this.tmRooms.getCellValueForSelectedRow(1).toString());
        Double price = Double.parseDouble(this.tmRooms.getCellValueForSelectedRow(2).toString());
        
        this.selectedRoom = KASGroup2.getCoreHandlerInstance().getRoom(this.txtHotelName.getText(), rt.toString());
        
        RoomService rs = this.selectedRoom.getRoomService();
        this.txtRoomServiceName.setText(rs.getName());
        this.txtRoomServiceDescription.setText(rs.getDescription());
        this.txtRoomServicePrice.setText(rs.getPrice().toString());
        
        //selectedRoom = new Room(rt, price, new RoomService("", "", 0.0));
        this.cmbRoomType.setSelectedItem(rt);
        this.txtRoomAmount.setText(amount.toString());
        this.txtRoomPrice.setText(price.toString());
        //this.txtRoomPrice.setText(this.rooms.);
    }//GEN-LAST:event_tblRoomsMouseClicked

    private void btnCreateHotelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateHotelActionPerformed
        // See constructor: UICreateHotelFrame(...)
    }//GEN-LAST:event_btnCreateHotelActionPerformed

    private void tblRoomServiceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblRoomServiceMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_tblRoomServiceMouseClicked

    private void btnAddRoomType1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddRoomType1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnAddRoomType1ActionPerformed

    private void btnDeleteRoom1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteRoom1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnDeleteRoom1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(UICreateHotelFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(UICreateHotelFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(UICreateHotelFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(UICreateHotelFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new UICreateHotelFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddRoomType;
    private javax.swing.JButton btnAddRoomType1;
    private javax.swing.JButton btnCreateHotel;
    private javax.swing.JButton btnDeleteRoom;
    private javax.swing.JButton btnDeleteRoom1;
    private javax.swing.JComboBox cmbRoomType;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable tblRoomService;
    private javax.swing.JTable tblRooms;
    private javax.swing.JTextArea txtHotelAddress;
    private javax.swing.JTextField txtHotelName;
    private javax.swing.JFormattedTextField txtRoomAmount;
    private javax.swing.JFormattedTextField txtRoomPrice;
    private javax.swing.JFormattedTextField txtRoomServiceDescription;
    private javax.swing.JFormattedTextField txtRoomServiceName;
    private javax.swing.JFormattedTextField txtRoomServicePrice;
    // End of variables declaration//GEN-END:variables

    private void addRow(Room r, int amount) {
        this.tmRooms.addRow(new Object[] { r.getRoomType().toString(), amount, r.getRoomTotalPrice() });
    }
    
    private Room makeRoom() {
        EnumRoomType roomType = EnumRoomType.valueOf(this.cmbRoomType.getSelectedItem().toString());
        double roomPrice = 0;
        roomPrice = Double.parseDouble(this.txtRoomPrice.getText());
        return new Room(roomType, roomPrice, new RoomService("", "", 0.0));
    }
}
